package com.shanghaiyimu.yimiyangche.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shanghaiyimu.yimiyangche.R;
import com.shanghaiyimu.yimiyangche.bean.HotTiewItemBean;

import java.util.List;

/**
 * Created by Administrator on 2017/7/7.
 */

public class HotTieAdapter extends BaseAdapter {

    private Context context;
    private List<HotTiewItemBean> data;

    public HotTieAdapter(Context context, List<HotTiewItemBean> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data!=null?data.size():0;
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.fragmenthottieitem,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.ques.setText(data.get(position).getWen());
        holder.answ.setText(data.get(position).getDa());
        return convertView;
    }

    static class ViewHolder{
        TextView ques,answ;
        public ViewHolder(View view) {
            ques = (TextView) view.findViewById(R.id.hot_item_ques_tv);
            answ = (TextView) view.findViewById(R.id.hot_item_anse_tv);
        }
    }
}
